<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>图纸分析</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="./../../../favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./../../../static/css/font.css">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="./../../../static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../../static/css/buildUnit/common.css">
    <script type="text/javascript" src="/lib/mxDraw/mxcustom.js"></script>
    <style>
        body {
            padding: 0;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            height:100%;
        }
        #content{
            height:100%;
        }
        .drawingObj {
            height: 100%;
            width: 100%;
        }
        #iStylePDF{
            vertical-align: middle;
        }
    </style>
</head>
<body>
<div class="layui-row" style="height: 100%">
    <div id="content" class="layui-col-xs8"></div>
    <div class="layui-col-xs4">
        <form class="layui-form searchForm" action="">

            <div class="layui-form-item" style="margin-bottom: 0px;">
                <div class="layui-inline">

                    <div class="layui-input-inline" style="width: 780px;">
                        <label class="layui-form-label">分析类型：</label>
                        <input class="formData" lay-filter="analysisType" type="radio" name="analysisType" value="0" title="质量巡查">
                        <input class="formData" lay-filter="analysisType" type="radio" name="analysisType" value="1" title="质量验收">
                        <input class="formData" lay-filter="analysisType" type="radio" name="analysisType" value="2" title="竣工验收">
                    </div>
                </div>
            </div>
        </form>
        <table class="layui-hide" id="dataList" lay-filter="dataList"></table>




    </div>
</div>


</div>

<script type="text/html" id="zgtzdBtn">
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="zgtzd">整改通知单</a>
</script>
<script type="text/html" id="zgfkdBtn">
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="zgfkd">整改反馈单</a>
</script>
<script type="text/html" id="dingwei">
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="dingwei">定位</a>
</script>
<script type="text/html" id="detailBtn">
    <a class="layui-btn layui-btn layui-btn-xs" lay-event="accDetail">详情</a>
</script>

<script src="../../../static/js/main.js"></script>
<!-- pdf批注完成事件 -->
<script language="javascript" for=iStylePDF event="OnAnnotFinished(Annot, wParam, lParam)">
    layui.use(['pdf'], function () {
        var pdf = layui.pdf;
        pdf.suggestAdd(Annot, wParam, lParam);
    });
</script>
<!-- pdf双击圈阅修改事件 -->
<script language="javascript" for=iStylePDF event="OnAddinEventInvoke(EventName, Addin, wParam, lParam)">
    if (EventName == "iStylePDF.Annots:LButtonDblClk") {
        layui.use(['pdf'], function () {
            var pdf = layui.pdf;
            pdf.suggestEdit(EventName, Addin, wParam, lParam);
        });
        Addin.MsgHandle = true;
    }
</script>
<script>
    //例子图纸：http://61.55.140.248:8094/ysb_store_path/drawing/6e6fbe961ac84e768f8e2c76fe65520d/761364b59d4a4804b695d9d95103ea83/b084bdeed5854c1ba80ecd5e1113bb2f.dwg
    layui.use([
        'layer',
        'mxDraw',
        'configure',
        'jquery',
        'sessionFun',
        'matchType',
        'bluebird',
        'pdf',
        'pdfXiaoling',
        'table',
        'configureCom'
    ], function () {
        var configure = layui.configure;
        var $ = layui.jquery;
        var mxDraw = layui.mxDraw;
        var sessionFun = layui.sessionFun;
        var matchType = layui.matchType;
        var pdf = layui.pdf;
        var pdfXiaoling = layui.pdfXiaoling;
        var token=localStorage.getToken;
        var table = layui.table;
        var configureCom = layui.configureCom;
        //获取当前审查对象
        var listData = sessionFun.get(configure.SESSION_PROJECT_WAIT_LIST_DATA);
        //获取文件树选中对象
        var fileTreeData = sessionFun.get(configure.SESSION_FILE_TREE_DATA);
        //获取当前图纸
        var drawingData = sessionFun.get(configure.SESSION_CKTZ_INFO_DATA);
        //通过图纸名称，获得图纸类型
        var fileType = configureCom.GetQueryString('fileType');//matchType.init(drawingData.name);
        var fileId = configureCom.GetQueryString('fileId');
        //demo图纸
        //var path = fileTreeData.path +'/'+ drawingData.name;
        //var url = configure.HOST + configure.DRAWING_WATCH + '?decId=' + listData.decId + '&filePath=' + encodeURIComponent(path) + '&token=' + configureCom.getToken();
        var url = 'http://61.55.140.248:7000/api/sys/doc/att/'+fileId+'?token='+token;
        if (fileType === 'pdf') {
            //pdf初始化
            pdf.init('iStylePDF', url, '#content');
            //pdfXiaoling.init('iStylePDF', url, '#content');
        } else {
            //cad图纸初始化
            mxDraw.init('drawingId', url, 'http://www.mxdraw.com/MxDrawX52.CAB#version=8.0.0.1', '#content');
        }

        form.on('radio(analysisType)', function(data){
            if(data.value==='0'){
                init0();
            }else if(data.value==='1'){
                init1();
            }else if(data.value==='2'){
                init2();
            }else{
                init0();
            }
        });

        /**
         * 初始化 质量巡查
         */
        function init0(){

            var queStatus = ['','待整改','待复查','已完成','超期未整改'];
            var queImageStatus = ['','point_red_1000.png','point_yellow_1000.png','point_green_1000.png','point_purple_1000.png'];
            // 在图上加载点
            configureCom.postDataAjax(configure.QLY_INSPECTION_DRAWING_ANALYSIS_API, { attId: fileId}).then(function (res) {
                if(res.code==0){
                    $.each(res.data,function(index,item){
                        if(item.poiData){
                            var point = JSON.parse(item.poiData)
                            mxDraw.mxOcx.DrawImage(point.dx, point.dy, 1, 0, 'http://61.55.140.248:7000/static/images/'+queImageStatus[item.queStatus]);
                        }
                    });
                    mxDraw.mxOcx.UpdateDisplay();
                }else{

                }
            });




            var cols = [[
//            {field: 'buildProjectLeaderId', title: '巡查部门'},
                {field: 'queNum', title: '问题数量'},
                {field: 'queStatus', title: '问题状态', templet: function (d) {
                        return queStatus[d.queStatus];
                    }
                },
                {fixed: 'right', title: '整改通知单', toolbar: '#zgtzdBtn'},
                {fixed: 'right', title: '整改反馈单', toolbar: '#zgfkdBtn'},
                {fixed: 'right', title: '定位', toolbar: '#dingwei'}
            ]];
            configureCom.tableRender(configure.QLY_INSPECTION_PAGE_API, { attId: fileId}, cols, 'dataList', 10, '', '');

            //每行操作
            table.on('tool(dataList)', function (obj) {
                var data = obj.data;
                sessionFun.set(configure.SESSION_QLY_INSPECTION_ROW_DATA, data);
                if (obj.event === 'zgtzd') {

                    top.layer.open({
                        type: 2,
                        title: '整改通知单',
                        area: configureCom.Psize1,
                        content: configureCom.nocache(configure.QLY_INSPECTION_ZGTZD_HTML),//+'?insId='+data.insId
                        success: function (layero, index) {
                            top.layer.full(index);
                        }
                    });

                } else if (obj.event === 'zgfkd') {
                    top.layer.open({
                        type: 2,
                        title: '整改通知单',
                        area: configureCom.Psize1,
                        content: configureCom.nocache(configure.QLY_INSPECTION_ZGFKD_HTML),
                        success: function (layero, index) {
                            top.layer.full(index);
                        }
                    });
                }else if (obj.event === 'showDrawing') {

                }else if (obj.event === 'dingwei') {
                    if(data.poiData){
                        var point = JSON.parse(data.poiData)
                        mxDraw.mxOcx.ZoomCenter(point.dx, point.dy);
                    }

                }
            });
        }

        /**
         * 质量验收
         */
        function init1(){


            // 在图上加载点
            configureCom.postDataAjax(configure.QLY_ACCEPTANCE_DRAWING_ANALYSIS_API, { attId: fileId}).then(function (res) {
                if(res.code==0){
                    $.each(res.data,function(index,item){
                        if(item.poiData){
                            var point = JSON.parse(item.poiData)
                            mxDraw.mxOcx.DrawImage(point.dx, point.dy, 0, 0, 'http://61.55.140.248:7000/static/images/point_red_1000.png');
                        }
                    });
                }else{

                }
            });



            var accType = ['','地基工程','防水工程','钢筋隐蔽工程','混凝土工程','屋面工程','其他'];
            var cols = [[
                {field: 'prjAreaName', title: '验收部位'},
                {field: 'accType', title: '验收类型', templet: function (d) {
                        return accType[d.accType];
                    }
                },
                {field: 'accContent', title: '验收内容'},
                // {field: 'accTime', title: '验收时间'},
                {fixed: 'right', title: '详情', toolbar: '#detailBtn'},
                {fixed: 'right', title: '定位', toolbar: '#dingwei'}
            ]];
            configureCom.tableRender(configure.QLY_ACCEPTANCE_PAGE_API, { attId: fileId}, cols, 'dataList', 10, '', '');

            //每行操作
            table.on('tool(dataList)', function (obj) {
                var data = obj.data;
                sessionFun.set(configure.SESSION_QLY_ACCEPTANCE_ROW_DATA, data);
                if (obj.event === 'accDetail') {
                    top.layer.open({
                        type: 2,
                        title: '质量验收详情',
                        area: configureCom.Psize1,
                        content: configureCom.nocache(configure.QLY_ACCEPTANCE_DETAIL_HTML),
                        success: function (layero, index) {
                            top.layer.full(index);
                        }
                    });
                }else if (obj.event === 'dingwei') {
                    if(data.poiData){
                        var point = JSON.parse(data.poiData)
                        mxDraw.mxOcx.ZoomCenter(point.dx, point.dy);
                    }
                }
            });
        }

        function init2() {

        }


    });

</script>
</body>
</html>